<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;

class ArticleComment extends Model
{
    use HasDateTimeFormatter;

    protected $fillable = [
        'parent_id',
        'article_id',
        'user_id',
        'content',
        'image',
    ];

    protected $attributes = [
        'image'  => '',
        'parent_id' => 0,
        'audit_status' => 2
    ];

    public function user()
    {
        return $this->belongsTo(User::class,'user_id');
    }

    public function article()
    {
        return $this->belongsTo(Article::class,'article_id');
    }


    public function identity()
    {
        return $this->hasOne(UserIdentity::class,'user_id','id');
    }

    public function son()
    {
        return $this->hasMany(ArticleComment::class,'parent_id');
    }
}
